package ph.com.gs3.formalistics;

import ph.com.gs3.formalistics.global.constants.Constants;
import ph.com.gs3.formalistics.global.constants.LoggingType;
import ph.com.gs3.formalistics.services.managers.DataSynchronizationManager;
import ph.com.gs3.formalistics.services.managers.SessionManager;
import ph.com.gs3.formalistics.services.synchronizers.DocumentsSynchronizer;
import ph.com.gs3.formalistics.services.synchronizers.FormsSynchronizer;
import android.app.Application;

public class MainApplication extends Application {

	@Override
	public void onCreate() {
		super.onCreate();

		Constants.createApplicationInstace(getApplicationContext());

		initializeSingletonSessionManager();
		configureLogging();

	}

	private void initializeSingletonSessionManager() {

		// Singleton Managers
		SessionManager sessionManager = SessionManager
		        .createApplicationInstance(getApplicationContext());

		DataSynchronizationManager.createApplicationInstance(getApplicationContext());

		// Manager Background Tasks
		sessionManager.startListeningToNetworkChanges();

	}

	private void configureLogging() {

		// FullUpdateManager.LOGGING_TYPE = LoggingType.ENABLED;
		FormsSynchronizer.LOGGING_TYPE = LoggingType.ENABLED;
		DocumentsSynchronizer.LOGGING_TYPE = LoggingType.ENABLED;
		// CommentsSynchronizer.LOGGING_TYPE = LoggingType.ENABLED;

		// OutgoingActionsSynchronizer.LOGGING_TYPE = LoggingType.ENABLED;

	}

}
